<!DOCTYPE HTML>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
	<title>fastclick解决穿透</title>

	<style type="text/css">
	body{
		margin: 0;
	}
	.container{
		width: 100%;
		overflow: hidden;
		position: relative;
	}
	.layer-title{
		width: 100%;
		margin: 50px 0;
		text-align: center;
	}
	.layer-action{
		position: absolute;
		bottom: 20px;
		width: 100%;
		text-align: center;
	}
	.btn{
		background-color: #08c;
		border: 0;
		color: #fff;
		height: 30px;
		line-height: 30px;
		width: 100px;
	}

	#underLayer{
		background-color: #eee;
		width: 90%;
		height: 500px;
		line-height: 500px;
		margin: 30px auto 200px;
		text-align: center;
	}

	#popupLayer{
		/*display: none;*/
		background-color: #fff;
		width: 80%;
		height: 200px;
		position: fixed;
		top: 50%;
		left: 50%;
		margin-left: -40%;
		margin-top: -100px;
		z-index: 1;
	}

	#bgMask{
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		background-color: rgba(0,0,0,0.6);
	}
	</style>
</head>
<body>
	<div class="container">
		<div id="underLayer">底层元素</div>

		<div id="popupLayer">
			<div class="layer-title">弹出层</div>
			<div class="layer-action">
				<button class="btn" id="closePopup">关闭</button>
			</div>
		</div>
	</div>
	<div id="bgMask"></div>


	<script src="js/zepto.min.js"></script>
	<script src="fastclick/fastclick.js"></script>
	<script type="text/javascript">
	
		FastClick.attach(document.body);

		// 点击穿透
		var $close = $('#closePopup');
		var $popup = $('#popupLayer');
		var $under = $('#underLayer');
		var $mask = $('#bgMask'); 

		$close.on('click', function(e){
			$popup.hide();
			$mask.hide();
		});

		$under.on('click', function(){
			alert('underLayer clicked');
		});

	//other means 监听touchend事件，并在事件中使用preventDefault()阻止；
	//$("#closePopup").on("touchend",function(event) {
 //   event.preventDefault();
 // });
 // 
 // 
 //   if ('addEventListener' in document) {
    // document.addEventListener('DOMContentLoaded', function() {
    //     FastClick.attach(document.body);
    // }, false);
	</script>
</body>
</html>